function BXFMSearch(e){this.Init(e)}BXFMSearch.prototype={Init:function(e){if(this.bInited)return true;var t=this;this.pAddLink=BX("bx_fms_add_lnk");this.pSearchTbl=BX("bx_fms_tbl");this.oSearchDialog=e.oSearchDialog;this.pTabSearch=BX("bx_search_cont");this.pTabReplace=BX("bx_replace_cont");this.lang=e.lang;this.site=e.site;this.arLastPathes=e.arLastPathes;this.sessid_get=e.sessid_get;this.bUseLastValues=true;this.viewMsFilePath=e.viewMsFilePath;this.viewMsFolderPath=e.viewMsFolderPath;this.dateFormat=e.dateFormat;this.pForm=document.forms["bx_search_form"];this.pSearchResultCont=BX("bx_search_res_cont");this.pSearchFile=BX("bx_search_file");this.pSearchPhrase=BX("bx_search_phrase");this.pReplacePhrase=BX("bx_replace_phrase");this.pSearchDir=BX("bx_search_dir");this.pSearchSubdir=BX("bx_search_subdir");this.pSearchDirsToo=BX("bx_search_dirs_too");this.pSearchEntire=BX("bx_search_entire");this.pSearchCase=BX("bx_search_case");this.pInResRow=BX("bx_search_in_res_tr");this.pInRes=BX("bx_search_in_res");this.pFDButton=BX("bx_search_fd_but");this.pSearchDateSel=BX("bx_search_date_sel");this.pSearchDateFrom=BX("bx_search_date_from");this.pSearchDateTo=BX("bx_search_date_to");this.pSearchDateDiv=BX("bx_search_date_div");this.pSearchSizeSel=BX("bx_search_size_sel");this.pSearchSizeFrom=BX("bx_search_size_from");this.pSearchSizeTo=BX("bx_search_size_to");this.pSearchSizeDiv=BX("bx_search_size_div");this.pSearchSubdir.onclick=this.pSearchDirsToo.onclick=this.pSearchEntire.onclick=this.pSearchCase.onclick=function(){t.SaveConfig()};this.pAddLink.onclick=function(e){var s=t.pSearchTbl.className.indexOf("bxfm-d-params-add-hide")==-1;t.bShowAdvanced=!s;if(s)BX.addClass(t.pSearchTbl,"bxfm-d-params-add-hide");else BX.removeClass(t.pSearchTbl,"bxfm-d-params-add-hide");t.oSearchDialog.adjustSizeEx();t.SaveConfig();return false};this.pSearchDateSel.onchange=function(){t.pSearchDateDiv.style.display=this.value=="set"?"block":"none";t.oSearchDialog.adjustSizeEx();if(this.value!==0){var e=new Date,s=new Date,i=s.getMonth(),a=s.getFullYear(),l=s.getDate(),o=s.getHours(),n=s.getMinutes();t.pSearchDateTo.value=""}if(this.value==0){t.pSearchDateFrom.value="";t.pSearchDateTo.value=""}else if(this.value=="day"){e.setFullYear(a,i,l-1);t.pSearchDateFrom.value=t.FormatDate(e.getDate(),e.getMonth(),e.getFullYear(),o,n)}else if(this.value=="week"){e.setFullYear(a,i,l-7);t.pSearchDateFrom.value=t.FormatDate(e.getDate(),e.getMonth(),e.getFullYear(),o,n)}else if(this.value=="month"){e.setFullYear(a,i-1,l);t.pSearchDateFrom.value=t.FormatDate(e.getDate(),e.getMonth(),e.getFullYear(),o,n)}else if(this.value=="year"){e.setFullYear(a-1,i,l);t.pSearchDateFrom.value=t.FormatDate(e.getDate(),e.getMonth(),e.getFullYear(),o,n)}};this.pSearchSizeSel.onchange=function(){t.pSearchSizeDiv.style.display=this.value=="set"?"block":"none";t.oSearchDialog.adjustSizeEx();if(this.value==0){t.pSearchSizeFrom.value="";t.pSearchSizeTo.value=""}else if(this.value=="100"){t.pSearchSizeFrom.value="";t.pSearchSizeTo.value="100"}else if(this.value=="100_500"){t.pSearchSizeFrom.value="100";t.pSearchSizeTo.value="500"}else if(this.value=="500"){t.pSearchSizeFrom.value="500";t.pSearchSizeTo.value=""}};this.pInRes.onclick=function(){var e=!!this.checked;t.pFDButton.disabled=t.pSearchDir.disabled=t.pSearchSubdir.disabled=e};this.oSiteSel=new BXFMSiteSel({id:"site_sel_search",pDiv:BX("bx_search_site_sel"),sites:e.arSites});BX.addCustomEvent(oSearchDialog,"onWindowUnRegister",BX.proxy(this.OnClose,this));if(e.oUserConfig){this.bShowAdvanced=e.oUserConfig.advMode;if(this.bShowAdvanced)BX.removeClass(this.pSearchTbl,"bxfm-d-params-add-hide");else BX.addClass(this.pSearchTbl,"bxfm-d-params-add-hide");this.pSearchSubdir.checked=!!e.oUserConfig.bSubdir;this.pSearchDirsToo.checked=!!e.oUserConfig.bDirsToo;this.pSearchEntire.checked=!!e.oUserConfig.entire;this.pSearchCase.checked=!!e.oUserConfig.bCaseSens}this.Request("clean_old",{},false,false);this.bInited=true},OnOpen:function(e){this.sSess=e.ssess||false;this.SetPath(e.path);this.pInResRow.style.display=e.bSearch?"":"none";if(e.bSearch){if(this.pInRes.checked)this.pFDButton.disabled=this.pSearchDir.disabled=this.pSearchSubdir.disabled=true}else{this.pInRes.checked=false}if(e.lastValues&&this.bUseLastValues){this.bUseLastValues=false;this.pSearchFile.value=e.lastValues.file||"";this.pSearchPhrase.value=e.lastValues.search_phrase||"";this.pReplacePhrase.value=e.lastValues.replace_phrase||"";this.pSearchDir.value=e.lastValues.dir||"";this.pSearchSubdir.checked=!!e.lastValues.subdir;this.pSearchDirsToo.checked=!!e.lastValues.dirs_too;this.pSearchCase.checked=!!e.lastValues.case_sens;if(e.lastValues.date_sel){this.pSearchDateSel.value=e.lastValues.date_sel;this.pSearchDateSel.onchange();if(e.lastValues.date_from||e.lastValues.date_to){this.pSearchDateFrom.value=e.lastValues.date_from;this.pSearchDateTo.value=e.lastValues.date_to}}if(e.lastValues.size_sel){this.pSearchSizeSel.value=e.lastValues.size_sel;this.pSearchSizeSel.onchange();if(e.lastValues.size_from||e.lastValues.size_to){this.pSearchSizeFrom.value=e.lastValues.size_from;this.pSearchSizeTo.value=e.lastValues.size_to}}}this.pSearchFile.focus();BX.bind(BX.browser.IsIE()?document.body:window,"keydown",BX.proxy(this.OnKeyDown,this))},OnClose:function(){BX.unbind(BX.browser.IsIE()?document.body:window,"keydown",BX.proxy(this.OnKeyDown,this))},OnKeyDown:function(e){if(!e)e=window.event;if(window.oBXFileDialog&&window.oBXFileDialog.bOpened)return;if(oSearchDialog.isOpen&&e.keyCode==13)return this.Search()},Count:function(){var e=this,t=this.GetPostParams();var s=function(){if(!e.oCountResDialog.isOpen)return;if(window.fmsBtimeout){t.last_path=window.fmsLastPath;e.count_xhr=e.Request("count",t,s)}else{if(e.oCountResInt)clearInterval(e.oCountResInt);e.oCountResIntCount=0;BX.removeClass(e.pCountResDiv,"bxfm-count-wait");e.oCountResDialog.SetTitle(FM_MESS.CountEnded)}e.intCountResult+=window.fmsResult;if(window.fmsBstoped){e.pReplResCntWarn.style.display="inline";e.pCountResDiv.title=FM_MESS.CountLimitWarn}else{e.pReplResCntWarn.style.display="none";e.pCountResDiv.title=""}e.pCountResCnt.innerHTML=e.intCountResult};if(!e.oCountResDialog){this.oCountResDialog=new BX.CDialog({title:FM_MESS.CountProgress,content:'<div id="bxfm_count_res_div" class="bxfm-count-res-div bxfm-count-wait">'+FM_MESS.CountedFiles+': <span id="bxfm_count_res_cnt">0</span><span id="bxfm_cnt_res_warn" class="bxfm-warn">*</span></div>',height:125,width:250,resizable:false,buttons:[BX.CDialog.btnClose]});this.pCountResCnt=BX("bxfm_count_res_cnt");this.pCountResDiv=BX("bxfm_count_res_div");this.pReplResCntWarn=BX("bxfm_cnt_res_warn");BX.addClass(this.oCountResDialog.PARTS.CONTENT,"bxfm-dialog-content");if(BX.browser.IsIE())this.pCountResDiv.style.margin="3px 0 2px 2px"}else{e.pCountResCnt.innerHTML="0";e.pReplResCntWarn.style.display="none";e.pCountResDiv.title="";BX.addClass(e.pCountResDiv,"bxfm-count-wait");this.oCountResDialog.SetTitle(FM_MESS.CountProgress)}this.oCountResDialog.Show();this.intCountResult=0;if(this.oCountResInt)clearInterval(this.oCountResInt);this.oCountResIntCount=0;this.oCountResInt=setInterval(function(){if(e.oCountResIntCount<3){e.oCountResIntCount++;e.oCountResDialog.SetTitle(e.oCountResDialog.PARAMS.title+" .")}else{e.oCountResIntCount=0;e.oCountResDialog.SetTitle(FM_MESS.CountProgress)}},400);if(this.count_xhr)this.count_xhr.abort();this.count_xhr=this.Request("count",t,s);BX.addCustomEvent(this.oCountResDialog,"onWindowUnRegister",BX.proxy(function(){if(this.count_xhr)this.count_xhr.abort()},this))},Search:function(){if(this.bReplace)return this.Replace();var e=this,t=this.GetPostParams();var s=function(){if(!e.oSearchResDialog.isOpen||e.bSearchDenied)return;var i,a=window.fmsResult.length,l,o,n,r;if(a>0&&e.arSearchResult.length==0){e.pSearchRes.style.display="block";e.oSearchResDialog.PARAMS.buttons[0].enable();e.oSearchResDialog.SetSize({width:600,height:400});e.oSearchResDialog.adjustPos()}for(i=0;i<a;i++){n=window.fmsResult[i];e.arSearchResult.push(n);e.searchCount+=parseInt(n.repl_count);l=e.pSearchResTable.insertRow(-1);l.title=n.path;o=l.insertCell(-1);o.appendChild(BX.create("IMG",{props:{src:n.type_src}}));o=l.insertCell(-1);o.style.textAlign="left";r=((n.b_dir?e.viewMsFolderPath:e.viewMsFilePath)+e.oSiteSel.value).replace("#PATH#",BX.util.urlencode(n.path));o.appendChild(BX.create("A",{props:{href:r,target:"_blank"},text:n.path}));if(e.pSearchPhrase.value!="")o.appendChild(BX.create("SPAN",{props:{className:"bxfm-search-cnt",title:FM_MESS.SearchInFileTitle},html:" (<span>"+parseInt(n.repl_count)+"</span>)"}));o=l.insertCell(-1);o.appendChild(document.createTextNode(n.str_date));o=l.insertCell(-1);o.appendChild(document.createTextNode(n.str_size))}if(e.pSearchPhrase.value==""){e.pSearchResCnt.innerHTML=e.arSearchResult.length||0}else{e.pSearchResCnt.innerHTML=e.searchCount||0;e.pSearchResCntFiles.innerHTML=e.arSearchResult.length||0}if(window.fmsBtimeout){t.last_path=window.fmsLastPath;e.xhr=e.Request("search",t,s)}else{if(e.oSearchResInt)clearInterval(e.oSearchResInt);e.oSearchResIntCount=0;var h=BX("stop");if(h)h.disabled=true;BX.removeClass(e.pSearchResDiv,"bxfm-wait");e.oSearchResDialog.PARAMS.buttons[0].enable();e.oSearchResDialog.SetTitle(FM_MESS.SearchEnded)}if(window.fmsBstoped){e.pSearchResCntWarn.style.display="inline";e.pSearchResDiv.title=FM_MESS.CountLimitWarn}else{e.pSearchResCntWarn.style.display="none";e.pSearchResDiv.title=""}};if(!this.oSearchResDialog){this.oSearchResDialog=new BX.CDialog({title:FM_MESS.SearchProgress,content:'<div id="bxfm_search_res_div" class="bxfm-search-res-div bxfm-wait"><div class="bxfm-wait-1"></div>'+FM_MESS.Counted+': <span id="bxfm_search_res_cnt">0</span><span id="bxfm_sres_warn" class="bxfm-warn">*</span><span class="bxfm-only-for-phrase"><br>'+FM_MESS.ReplCountInFiles+': <span id="bxfm_search_res_files">0</span></span><div class="bxfm-search-res" id="bxfm_search_res"><table><tr class="bxfm-s-res-head"><td class="bxfm-h-type"></td><td class="bxfm-h-path">'+FM_MESS.Path+'</td><td class="bxfm-h-date">'+FM_MESS.Date+'</td><td class="bxfm-h-size">'+FM_MESS.Size+"</td></tr></table></div></div>",height:125,width:450,min_height:220,min_width:450,buttons:[new BX.CWindowButton({title:FM_MESS.ShowRes,id:"show_res",name:"show_res",action:function(){e.DisplaySearchResult()}}),new BX.CWindowButton({title:FM_MESS.Stop,id:"stop",name:"stop",action:function(){if(e.oSearchResInt)clearInterval(e.oSearchResInt);e.oSearchResIntCount=0;e.bSearchDenied=true;if(e.xhr)e.xhr.abort();BX.removeClass(e.pSearchResDiv,"bxfm-wait");e.oSearchResDialog.PARAMS.buttons[0].enable();e.oSearchResDialog.SetTitle(FM_MESS.SearchEnded)}}),BX.CDialog.btnClose]});BX.addClass(this.oSearchResDialog.PARTS.CONTENT,"bxfm-dialog-content");this.pSearchResCnt=BX("bxfm_search_res_cnt");this.pSearchResCntFiles=BX("bxfm_search_res_files");this.pSearchRes=BX("bxfm_search_res");this.pSearchResTable=this.pSearchRes.firstChild;this.pSearchResDiv=BX("bxfm_search_res_div");this.pSearchResCntWarn=BX("bxfm_sres_warn");if(BX.browser.IsIE())this.pSearchResDiv.style.margin="3px 0 2px 2px"}else{e.pSearchRes.style.display="none";e.pSearchResCnt.innerHTML="0";e.pSearchResCntFiles.innerHTML="0";while(this.pSearchResTable.rows[1])this.pSearchResTable.deleteRow(-1);this.pSearchResCntWarn.style.display="none";this.pSearchResDiv.title="";BX.addClass(this.pSearchResDiv,"bxfm-wait");BX.removeClass(this.pSearchResDiv,"bxfm-with-phrase");e.oSearchResDialog.SetTitle(FM_MESS.SearchProgress);e.oSearchResDialog.PARAMS.buttons[1].enable();e.oSearchResDialog.SetSize({width:600,height:125});e.oSearchResDialog.adjustPos()}this.oSearchResDialog.Show();this.arSearchResult=[];this.searchCount=0;this.bSearchDenied=false;this.oSearchResDialog.PARAMS.buttons[0].disable();if(this.pSearchPhrase.value!="")BX.addClass(this.pSearchResDiv,"bxfm-with-phrase");this.oSearchResIntCount=0;if(this.oSearchResInt)clearInterval(this.oSearchResInt);this.oSearchResInt=setInterval(function(){if(e.oSearchResIntCount<3){e.oSearchResIntCount++;e.oSearchResDialog.SetTitle(e.oSearchResDialog.PARAMS.title+" .")}else{e.oSearchResIntCount=0;e.oSearchResDialog.SetTitle(FM_MESS.SearchProgress)}},400);if(this.xhr)this.xhr.abort();this.xhr=this.Request("search",t,s);BX.addCustomEvent(this.oSearchResDialog,"onWindowUnRegister",BX.proxy(function(){if(this.xhr)this.xhr.abort()},this));BX.addCustomEvent(this.oSearchResDialog,"onWindowResizeExt",function(t){var s=t.width-35;if(BX.browser.IsIE()){s-=5}if(s>0)e.pSearchRes.style.width=s+"px"})},Replace:function(){BX.WindowManager.disableKeyCheck();if(this.pSearchPhrase.value==""){alert(FM_MESS.ReplacePhraseWarn);this.pSearchPhrase.focus();return setTimeout(function(){BX.WindowManager.enableKeyCheck()},500)}if(!confirm(FM_MESS.ReplaceConfirm))return setTimeout(function(){BX.WindowManager.enableKeyCheck()},500);BX.WindowManager.enableKeyCheck();var e=this,t=this.GetPostParams();var s=function(){if(!e.oReplaceResDialog.isOpen||e.bReplaceDenied)return;var i,a=window.fmsResult.length,l,o,n;if(a>0&&e.arReplaceResult.length==0){e.pReplRes.style.display="block";e.oReplaceResDialog.PARAMS.buttons[0].enable();e.oReplaceResDialog.SetSize({width:600,height:400});e.oReplaceResDialog.adjustPos()}for(i=0;i<a;i++){n=window.fmsResult[i];e.arReplaceResult.push(n);e.replaceCount+=parseInt(n.repl_count);l=e.pReplResTable.insertRow(-1);l.title=n.path;o=l.insertCell(-1);o.appendChild(BX.create("IMG",{props:{src:n.type_src}}));o=l.insertCell(-1);o.style.textAlign="left";href=((n.b_dir?e.viewMsFolderPath:e.viewMsFilePath)+e.oSiteSel.value).replace("#PATH#",BX.util.urlencode(n.path));o.appendChild(BX.create("A",{props:{href:href,target:"_blank"},text:n.path}));o.appendChild(BX.create("SPAN",{props:{className:"bxfm-rep-cnt",title:FM_MESS.ReplInFileTitle},html:" (<span>"+parseInt(n.repl_count)+"</span>)"}));o=l.insertCell(-1);o.appendChild(document.createTextNode(n.str_date));o=l.insertCell(-1);o.appendChild(document.createTextNode(n.str_size))}e.pReplResFilesCnt.innerHTML=e.arReplaceResult.length||0;e.pReplResCnt.innerHTML=e.replaceCount||0;if(window.fmsBtimeout){t.last_path=window.fmsLastPath;e.replace_xhr=e.Request("replace",t,s)}else{if(e.oReplResInt)clearInterval(e.oReplResInt);e.oReplResIntCount=0;var r=BX("stop");if(r)r.disabled=true;BX.removeClass(e.pReplResDiv,"bxfm-wait");e.oReplaceResDialog.PARAMS.buttons[0].enable();e.oReplaceResDialog.SetTitle(FM_MESS.ReplEnded)}if(window.fmsBstoped){e.pReplResCntWarn.style.display="inline";e.pReplResDiv.title=FM_MESS.CountLimitWarn}else{e.pReplResCntWarn.style.display="none";e.pReplResDiv.title=""}};if(!this.oReplaceResDialog){this.oReplaceResDialog=new BX.CDialog({title:FM_MESS.ReplProgress,content:'<div id="bxfm_repl_res_div" class="bxfm-search-res-div bxfm-wait"><div class="bxfm-wait-1"></div>'+FM_MESS.ReplCounted+': <span id="bxfm_repl_res_cnt">0</span><br>'+FM_MESS.ReplCountInFiles+': <span id="bxfm_repl_res_files">0</span><span id="bxfm_repl_res_warn" class="bxfm-warn">*</span><div class="bxfm-search-res" id="bxfm_repl_res"><table><tr class="bxfm-s-res-head"><td class="bxfm-h-type"></td><td class="bxfm-h-path">'+FM_MESS.Path+'</td><td class="bxfm-h-date">'+FM_MESS.Date+'</td><td class="bxfm-h-size">'+FM_MESS.Size+"</td></tr></table></div></div>",height:150,width:450,min_height:250,min_width:450,buttons:[new BX.CWindowButton({title:FM_MESS.ReplShowRes,id:"show_res",name:"show_res",action:function(){e.DisplayReplaceResult()}}),new BX.CWindowButton({title:FM_MESS.Stop,id:"stop",name:"stop",action:function(){if(e.oReplResInt)clearInterval(e.oReplResInt);e.oReplResIntCount=0;e.bReplaceDenied=true;if(e.replace_xhr)e.replace_xhr.abort();BX.removeClass(e.pReplResDiv,"bxfm-wait");e.oReplaceResDialog.PARAMS.buttons[0].enable();e.oReplaceResDialog.SetTitle(FM_MESS.ReplEnded)}}),BX.CDialog.btnClose]});BX.addClass(this.oReplaceResDialog.PARTS.CONTENT,"bxfm-dialog-content");this.pReplResCnt=BX("bxfm_repl_res_cnt");this.pReplResFilesCnt=BX("bxfm_repl_res_files");this.pReplRes=BX("bxfm_repl_res");this.pReplResTable=this.pReplRes.firstChild;this.pReplResDiv=BX("bxfm_repl_res_div");this.pReplResCntWarn=BX("bxfm_repl_res_warn");if(BX.browser.IsIE())this.pReplResDiv.style.margin="4px 2px 2px 0px"}else{e.pReplRes.style.display="none";e.pReplResCnt.innerHTML="0";e.pReplResFilesCnt.innerHTML="0";while(this.pReplResTable.rows[1])this.pReplResTable.deleteRow(-1);e.pReplResCntWarn.style.display="none";e.pReplResDiv.title="";BX.addClass(this.pReplResDiv,"bxfm-wait");this.oReplaceResDialog.SetTitle(FM_MESS.ReplProgress);this.oReplaceResDialog.PARAMS.buttons[1].enable();this.oReplaceResDialog.SetSize({width:600,height:120});this.oReplaceResDialog.adjustPos()}this.oReplaceResDialog.Show();this.arReplaceResult=[];this.replaceCount=0;this.bReplaceDenied=false;this.oReplaceResDialog.PARAMS.buttons[0].disable();this.oReplResIntCount=0;if(this.oReplResInt)clearInterval(this.oReplResInt);this.oReplResInt=setInterval(function(){if(e.oReplResIntCount<3){e.oReplResIntCount++;e.oReplaceResDialog.SetTitle(e.oReplaceResDialog.PARAMS.title+" .")}else{e.oReplResIntCount=0;e.oReplaceResDialog.SetTitle(FM_MESS.ReplProgress)}},400);if(this.replace_xhr)this.replace_xhr.abort();this.replace_xhr=this.Request("replace",t,s);BX.addCustomEvent(this.oReplaceResDialog,"onWindowUnRegister",BX.proxy(function(){if(this.replace_xhr)this.replace_xhr.abort()},this));BX.addCustomEvent(this.oReplaceResDialog,"onWindowResizeExt",function(t){var s=t.width-35;e.pReplRes.style.width=s+"px"})},GetPostParams:function(){return{file:this.pSearchFile.value,phrase:this.pSearchPhrase.value,replace_phrase:this.pReplacePhrase.value,dir:this.pSearchDir.value,subdir:this.pSearchSubdir.checked?1:0,date_from:this.pSearchDateFrom.value,date_to:this.pSearchDateTo.value,size_from:this.pSearchSizeFrom.value,size_to:this.pSearchSizeTo.value,entire:this.pSearchEntire.checked?1:0,case_sens:this.pSearchCase.checked?1:0,dirs_too:this.pSearchDirsToo.checked?1:0,ssess:this.sSess?this.sSess:0,in_result:this.pInRes.checked?1:0}},DisplayReplaceResult:function(){this.pSearchResultCont.appendChild(BX.create("INPUT",{props:{name:"is_replace",type:"hidden",value:"Y"}}));this.DisplaySearchResult(this.arReplaceResult)},DisplaySearchResult:function(e){if(typeof e!="object")e=this.arSearchResult;var t,s=e.length,i,a;for(t=0;t<s;t++){i="sres["+t+"]";a=e[t];this.pSearchResultCont.appendChild(BX.create("INPUT",{props:{name:i+"[path]",type:"hidden",value:a.path}}));this.pSearchResultCont.appendChild(BX.create("INPUT",{props:{name:i+"[b_dir]",type:"hidden",value:a.b_dir}}));this.pSearchResultCont.appendChild(BX.create("INPUT",{props:{name:i+"[size]",type:"hidden",value:a.size}}));this.pSearchResultCont.appendChild(BX.create("INPUT",{props:{name:i+"[time]",type:"hidden",value:a.time}}))}this.pForm.submit()},Request:function(e,t,s,i){i=i!==false;if(i)BX.showWait();var a="/bitrix/admin/fileman_admin.php?lang="+this.lang+"&fu_action="+e+"&site="+this.site+"&"+this.sessid_get+"&fu_site="+this.oSiteSel.value;return BX.ajax.post(a,t||{},function(e){if(i)BX.closeWait();if(s)setTimeout(function(){s(e)},100)})},SetTab:function(e){var t=this.oSearchDialog.PARAMS.buttons[0];if(e=="search"){this.pTabSearch.appendChild(this.pTabReplace.firstChild);t.btn.value=t.title=FM_MESS.Find;this.bReplace=false}else{this.pTabReplace.appendChild(this.pTabSearch.firstChild);t.btn.value=t.title=FM_MESS.Replace;this.bReplace=true}this.oSearchDialog.adjustSizeEx()},SetPath:function(e){this.pSearchDir.value=e},FormatDate:function(e,t,s,i,a){var l=this.dateFormat;l=l.replace(/DD/gi,this.ZeroInt(e));l=l.replace(/MM/gi,this.ZeroInt(t+1));l=l.replace(/YY(YY)?/gi,s);if(typeof i!=undefined&&typeof a!=undefined)l+=" "+i+":"+a+":00";return l},ZeroInt:function(e){e=parseInt(e,10);if(isNaN(e))e=0;return e<10?"0"+e.toString():e.toString()},SaveConfig:function(){this.Request("search_save_config",{adv_mode:this.bShowAdvanced?1:0,subdir:this.pSearchSubdir.checked?1:0,entire:this.pSearchEntire.checked?1:0,case_sens:this.pSearchCase.checked?1:0,dirs_too:this.pSearchDirsToo.checked?1:0},false,false)}};function BXFMServerPerm(e){this.Params=e;this.Params.bWindows=false;this.Init()}BXFMServerPerm.prototype={Init:function(){var e=this;this.pButSave=BX("bx_sp_save");this.pButApply=BX("bx_sp_apply");this.pButCancel=BX("bx_sp_cancel");this.pNoteSuccess=BX("bxsp_note_success");this.pRecursive=BX("bxsp_recurcive");this.InProcessMess=FM_MESS.InProcess+"...";this.pNoteErrors=BX("bxsp_note_errors");this.pNoteErrorsCont=BX("bxsp_note_errors_cont");this.pButSave.onclick=function(){return e.Process(true)};this.pButApply.onclick=function(){return e.Process(false)};this.pButCancel.onclick=function(){if(e.xhr){if(e.xhr)e.xhr.abort();e.xhr=false;e.bOnResultDenied=true;if(e.pCurValDiff)e.pCurValDiff.style.display="none";e.pButSave.disabled=e.pButApply.disabled=false;e.pButCancel.value=FM_MESS.Return;e.pButCancel.Title=FM_MESS.ReturnTitle;for(var t=1,s=e.pFileList.rows.length;t<s;t++){cell=e.pFileList.rows[t].cells[3];if(cell.innerHTML==e.InProcessMess)cell.innerHTML=FM_MESS.Stoped}}else{window.location=e.Params.backUrl}};this.pFileList=BX("bxsp_file_list");this.pCurValDiff=BX("bxsp_cur_val_diff");var t,s;this.arOwners=["owner","group","public"];this.arFields={};this.pResVal=BX("bxsp_res_value");this.pResVal.onblur=BX.proxy(this.SetValue2Checkboxes,this);this.pResVal.onkeyup=function(){if(this.value.length>=3)e.SetValue2Checkboxes()};for(t=0;t<3;t++){s=this.arOwners[t];this.arFields[s]={read:BX("bxsp_"+s+"_read"),write:BX("bxsp_"+s+"_write"),exec:BX("bxsp_"+s+"_exec"),value:BX("bxsp_"+s+"_value")};this.arFields[s].read.onclick=this.arFields[s].write.onclick=this.arFields[s].exec.onclick=BX.proxy(this.ChOnChange,this)}if(this.Params.currentValue){this.pResVal.value=this.Params.currentValue;this.SetValue2Checkboxes()}},ChOnChange:function(){var e="",t,s,i;for(t=0;t<3;t++){s=this.arOwners[t];i=(this.arFields[s].read.checked?"1":"0")+(this.arFields[s].write.checked?"1":"0")+(this.arFields[s].exec.checked?"1":"0");i=parseInt(i,2);this.arFields[s].value.value=i;e+=i}this.pResVal.value=e},SetValue2Checkboxes:function(){var e,t,s,i="",a,l=this.pResVal.value||"";if(l.length!=3)l="000";for(e=0;e<3;e++){s=parseInt(l.substr(e,1));if(isNaN(s)||s>7||s<0)s=0;i+=s.toString();t=this.arOwners[e];this.arFields[t].value.value=s;a=s.toString(2);if(a.length==1)a="00"+a;if(a.length==2)a="0"+a;this.arFields[t].read.checked=a.substr(0,1)==1;this.arFields[t].write.checked=a.substr(1,1)==1;this.arFields[t].exec.checked=a.substr(2,1)==1}this.pResVal.value=i},Request:function(e,t,s,i){i=i!==false;if(i)BX.showWait();return BX.ajax.post("/bitrix/admin/fileman_server_access.php?lang="+this.Params.lang+"&fu_action="+e+"&site="+this.Params.site+"&"+this.Params.sessid_get,t||{},function(e){if(i)BX.closeWait();if(s)setTimeout(function(){s(e)},100)})},Process:function(e){var t,s,i=this.Params.arFiles.length,a=[],l=this.pFileList.rows.length,o=this;this.bOnResultDenied=false;for(s=0;s<i;s++)a.push(this.Params.arFiles[s]["NAME"]);for(s=1;s<l;s++)this.pFileList.rows[s].cells[3].innerHTML=this.InProcessMess;this.pNoteSuccess.style.display="none";this.pNoteErrors.style.display="none";BX.cleanNode(this.pNoteErrorsCont);BX.removeClass(this.pFileList,"bxsp-file-list-init");var n={files:a,recurcive:this.pRecursive&&this.pRecursive.checked?"Y":"N",path:this.Params.path};if(this.Params.bSearch){n.search="Y";n.ssess=this.Params.searchSess}n.res_value=this.pResVal.value;var r=function(t){if(o.bOnResultDenied)return;var s,i=window.spResult.length,a,l,h,p,c,u,d,f,S,b,_,C,m,w=o.Params.arFiles.length;for(s=0;s<i;s++){h=window.spResult[s][0];p=false;for(C=0;C<w;C++){m=o.Params.arFiles[C]["PATH"];c=o.pResVal.value;if(h==m){u=BX("bxsp_file_row_"+C);u.cells[2].innerHTML="<b>"+c+"</b>";u.cells[2].title="";if(window.spResult[s][1])u.cells[3].innerHTML="<span class='bxsp-green'>"+FM_MESS.Ok+"</span>";else u.cells[3].innerHTML="<span class='bxsp-red'>"+FM_MESS.Error+"</span>";p=true;break}}if(!p&&!window.spResult[s][1]){o.pNoteErrors.style.display="block";o.pNoteErrorsCont.appendChild(BX.create("DIV",{text:h}))}}if(window.spBtimeout){n.last_path=window.spLastPath;o.xhr=o.Request("change_perms",n,r)}else{if(o.pCurValDiff)o.pCurValDiff.style.display="none";o.pNoteSuccess.style.display="block";o.pButSave.disabled=o.pButApply.disabled=false;o.pButCancel.value=FM_MESS.Return;o.pButCancel.Title=FM_MESS.ReturnTitle;o.xhr=false;if(e)setTimeout(function(){window.location=o.Params.backUrl},500)}};if(this.xhr)this.xhr.abort();this.xhr=this.Request("change_perms",n,r);this.pButSave.disabled=this.pButApply.disabled=true;this.pButCancel.value=FM_MESS.Stop;this.pButCancel.Title=FM_MESS.StopTitle;return false}};function BXFMCopy(e){this.Init(e)}BXFMCopy.prototype={Init:function(e){if(this.bInited)return true;this.oCopyDialog=e.oCopyDialog;BX.addClass(this.oCopyDialog.PARTS.CONTENT,"bx-fm-copy-dialog");BX.cleanNode(this.oCopyDialog.PARTS.CONTENT_DATA);this.oCopyDialog.PARTS.CONTENT_DATA.appendChild(BX("bx_copy_dialog"));this.arLastPathes=e.arLastPathes;var t=this;this.pAddLink=BX("bx_copy_add_lnk");this.pCopyTbl=BX("bx_copy_table");this.pFilelist=BX("bx_copy_file_list");this.pCopyTo=BX("bx_copy_to");this.pCaseAsk=BX("bx_copy_ask_user");this.pCaseReplace=BX("bx_copy_replace");this.pCaseAutoRename=BX("bx_copy_auto_rename");this.pCaseSkip=BX("bx_copy_skip");this.pCaseAsk.onclick=this.pCaseReplace.onclick=this.pCaseAutoRename.onclick=this.pCaseSkip.onclick=function(){if(this.checked)t.caseOption=this.value;t.SaveConfig()};this.lang=e.lang;this.site=e.site;this.sessid_get=e.sessid_get;BX("bx_copy_dialog").style.display="block";this.viewMsFilePath=e.viewMsFilePath;this.viewMsFolderPath=e.viewMsFolderPath;this.oSiteSel=new BXFMSiteSel({id:"site_sel_copy",pDiv:BX("bx_copy_site_sel"),sites:e.arSites});this.oCopyTo=new BXFMInpSel({id:"cm_copy_to",pInput:this.pCopyTo,Items:this.arLastPathes});this.pAddLink.onclick=function(){var e="bx-copy-cont-tbl-add-hide",s=t.pCopyTbl.className.indexOf(e)==-1;t.bShowAdvanced=!s;if(s)BX.addClass(t.pCopyTbl,e);else BX.removeClass(t.pCopyTbl,e);t.oCopyDialog.adjustSizeEx();t.SaveConfig();return false};this.caseOption="ask";if(e.oUserConfig){this.bShowAdvanced=e.oUserConfig.advMode;if(this.bShowAdvanced)BX.removeClass(t.pCopyTbl,"bx-copy-cont-tbl-add-hide");else BX.addClass(t.pCopyTbl,"bx-copy-cont-tbl-add-hide");this.caseOption=e.oUserConfig.caseOption||"ask"}switch(this.caseOption){case"ask":this.pCaseAsk.checked=true;break;case"replace":this.pCaseReplace.checked=true;break;case"auto_rename":this.pCaseAutoRename.checked=true;break;case"skip":this.pCaseSkip.checked=true;break}BX.addCustomEvent(this.oCopyDialog,"onWindowUnRegister",BX.proxy(this.OnClose,this));this.bInited=true},OnOpen:function(e){this.bCopy=e.bCopy;this.arFiles=[];this.curPath=e.path;this.bSearch=!!e.bSearch;this.searchSess=e.ssess;if(typeof e.arFiles=="object")this.arFiles=e.arFiles;var t=this.oCopyDialog.PARAMS.buttons[0];if(this.bCopy){this.oCopyDialog.SetTitle(FM_MESS.CopyTitle);t.btn.value=t.title=FM_MESS.Copy}else{this.oCopyDialog.SetTitle(FM_MESS.MoveTitle);t.btn.value=t.title=FM_MESS.Move}BX.cleanNode(this.pFilelist);var s,i=this.arFiles.length;for(s=0;s<i;s++){this.pFilelist.appendChild(BX.create("A",{props:{href:this.GetViewUrl(this.arFiles[s]),target:"_blank"},text:this.GetFileName(this.arFiles[s].path)}));if(s==1&&i>3){this.pFilelist.appendChild(document.createTextNode(" ("+FM_MESS.More.replace("#COUNT#",parseInt(i-s-1))+")"));break}else if(s<i-1){this.pFilelist.appendChild(document.createTextNode(", "))}}this.oCopyDialog.adjustSizeEx();BX.bind(BX.browser.IsIE()?document.body:window,"keydown",BX.proxy(this.OnKeyDown,this))},OnClose:function(){BX.unbind(BX.browser.IsIE()?document.body:window,"keydown",BX.proxy(this.OnKeyDown,this))},OnKeyDown:function(e){if(!e)e=window.event;if(window.oBXFileDialog&&window.oBXFileDialog.bOpened)return;if(this.oCopyDialog.isOpen&&e.keyCode==13&&(!this.oAskUserDialog||!this.oAskUserDialog.isOpen))return this.Process()},Process:function(e){var t=this,s=this.bCopy?"copy":"move",i={case_option:this.caseOption,files:this.arFiles,copy_to:this.pCopyTo.value},a=function(){if(window.BXFM_NoCopyToDir){if(window.BXFM_NoCopyToDir=="ask_user"&&confirm(FM_MESS.NoFolder.replace("#FOLDER#",t.pCopyTo.value))){i.create_copy_to="Y";t.Request(s,i,a)}else if(window.BXFM_NoCopyToDir=="access_denied"){alert(FM_MESS.NoFolderNoAccess.replace("#FOLDER#",t.pCopyTo.value))}window.BXFM_result=null;window.BXFM_NoCopyToDir=null}if(window.BXFM_fileExist){t.ShowAskUserDialog(window.BXFM_fileExist);window.BXFM_fileExist=null}if(window.BXFM_result){var e="";if(window.BXFM_result.status!="ok"){for(var l=0,o=window.BXFM_result.errors.length;l<o;l++)e+=window.BXFM_result.errors[l]+"\n"}if(e!=""){alert(e)}else{if(!t.bCopy||t.pCopyTo.value===t.curPath)window.location=t.bSearch?window.location:(t.viewMsFolderPath+t.site).replace("#PATH#",BX.util.urlencode(t.curPath));t.oCopyDialog.Close()}}};if(e){i.uc_answer=e.userCase;i.uc_to_all=e.applyToAll;i.uc_last_path=e.handledFilePath}if(this.bSearch){i.search="Y";i.ssess=this.searchSess}window.BXFM_noCopyToDir=window.BXFM_fileExist=window.BXFM_result=null;this.Request(s,i,a)},GetFileName:function(e){var t=e,s=e.lastIndexOf("/");if(s!==-1)t=e.substr(s+1);return t},GetViewUrl:function(e,t){var t=t||[false,""];if(t[0])return((!!e.isDir?this.viewMsFolderPath:this.viewMsFilePath)+t[1]).replace("#PATH#",BX.util.urlencode(e.path));return((!!e.isDir?this.viewMsFolderPath:this.viewMsFilePath)+this.site).replace("#PATH#",BX.util.urlencode(e.path))},SaveConfig:function(){this.Request("copy_save_config",{adv_mode:this.bShowAdvanced?1:0,case_option:this.caseOption},false,false)},Request:function(e,t,s,i){i=i!==false;if(i)BX.showWait();var a="/bitrix/admin/fileman_admin.php?lang="+this.lang+"&fu_action="+e+"&site="+this.site+"&"+this.sessid_get+"&fu_site="+this.oSiteSel.value;return BX.ajax.post(a,t||{},function(e){if(i)BX.closeWait();if(s)setTimeout(function(){s(e)},100)})},ShowAskUserDialog:function(e){var t=this;if(!this.oAskUserDialog){this.oAskUserDialog=new BX.CAdminDialog({title:"",content:"&nbsp;",height:240,width:600,resizable:false});this.oAskUserDialog.SetButtons([new BX.CWindowButton({title:FM_MESS.Replace,name:"replace",id:"ask_replace",action:function(){t.UserAnswer("replace")}}),new BX.CWindowButton({title:FM_MESS.Skip,name:"skip",action:function(){t.UserAnswer("skip")}}),new BX.CWindowButton({title:FM_MESS.Rename,name:"rename",action:function(){t.UserAnswer("auto_rename")}}),this.oAskUserDialog.btnCancel]);BX.addClass(this.oAskUserDialog.PARTS.CONTENT,"bx-fm-copy-dialog");BX.addClass(this.oAskUserDialog.PARTS.FOOT,"bx-core-dialog-foot-ask");setTimeout(function(){var e=BX("bx_copy_ask_dialog");t.oAskUserDialog.SetContent(e);e.style.display="block";t.pAskToAllCont=e.appendChild(BX.create("DIV",{props:{className:"bx-copy-to-all"},html:"<table><tr><td><input type='checkbox' id='bx_copy_ask_to_all'></td><td><label  for='bx_copy_ask_to_all'>"+FM_MESS.ToAll+"</label></td></tr></table>"}));t.oAskUserDialog.adjustSizeEx();BX.adminPanel.modifyFormElements(e)},50);this.pAskFileName=BX("bx_copy_ask_file_name");this.pAskFolderName=BX("bx_copy_ask_folder");this.pAskSizeRow=BX("bx_copy_ask_size_row");this.pAskFileNew={pName:BX("bx_copy_ask_file1"),pSize:BX("bx_copy_ask_size1"),pDate:BX("bx_copy_ask_date1")};this.pAskFileOld={pName:BX("bx_copy_ask_file2"),pSize:BX("bx_copy_ask_size2"),pDate:BX("bx_copy_ask_date2")};this.pNewNameCont=BX("bxc_ask_nn_cont1");this.pRenBut=this.oAskUserDialog.PARAMS.buttons[2].btn;this.pRenBut.onmouseover=function(){t._NewNamebShow=true;t._ShadeIn(true)};this.pRenBut.onmouseout=function(){t._NewNamebShow=false;setTimeout(function(){t._ShadeIn(false)},3e3)};BX.addCustomEvent(this.oAskUserDialog,"onWindowUnRegister",function(){t.oCopyTo.bDenyOpenPopup=false})}this.oAskUserDialog.Show();this.oCopyTo.bDenyOpenPopup=true;this.oAskUserDialog.adjustSizeEx();this.oAskUserDialog.SetTitle(e.fileNew.bDir?FM_MESS.FolderExistTitle:FM_MESS.FileExistTitle);var s=BX("ask_replace");if(this.curPath.replace(/[\s\r\n\/]+$/g,"")==this.pCopyTo.value.replace(/[\s\r\n\/]+$/g,"")&&s)s.disabled=true;else s.disabled=false;if(this.arFiles.length<=1)this.oAskUserDialog.PARAMS.buttons[1].btn.style.display="none";else this.oAskUserDialog.PARAMS.buttons[1].btn.style.display="";setTimeout(function(){t.pAskToAllCont.style.marginLeft=parseInt(t.oAskUserDialog.PARAMS.buttons[0].btn.offsetLeft)+"px";BX("bx_copy_ask_to_all").disabled=!!(t.arFiles.length<=1)},200);var i=[false,""];if(e.fileNew.site&&e.fileOld.site&&e.fileNew.site!==e.fileOld.site)i=[true,e.fileOld.site];this.pAskFileName.innerHTML=e.fileNew.name;this.pAskFolderName.innerHTML=this.pCopyTo.value;this.pAskFileOld.pName.innerHTML=this.pAskFileOld.pName.title=e.fileOld.name;this.pAskFileOld.pName.href=this.GetViewUrl({isDir:e.fileOld.bDir,path:e.fileOld.path},i);this.pAskFileOld.pDate.innerHTML=e.fileOld.date;this.pAskFileNew.pName.innerHTML=this.pAskFileNew.pName.title=e.fileNew.name;this.pAskFileNew.pName.href=this.GetViewUrl({isDir:e.fileNew.bDir,path:e.fileNew.path});this.pAskFileNew.pDate.innerHTML=e.fileNew.date;this.oAskUserDialog.newFilePath=e.fileNew.path;if(e.fileNew.size=="-"){this.pAskSizeRow.style.display="none"}else{this.pAskSizeRow.style.display="";this.pAskFileOld.pSize.innerHTML=e.fileOld.size;this.pAskFileNew.pSize.innerHTML=e.fileNew.size}this.pNewNameCont.innerHTML=this.pNewNameCont.title=e.fileNew.alt_name;this.pRenBut.title=FM_MESS.RenameTitle.replace("#NEW_NAME#",e.fileNew.alt_name)},UserAnswer:function(e){this.Process({userCase:e,applyToAll:BX("bx_copy_ask_to_all").checked?1:0,handledFilePath:this.oAskUserDialog.newFilePath});this.oAskUserDialog.Close()},_ShadeIn:function(e){if(this._NewNamebShow!=e)return;var t=this;if(this._shadeInInterval){clearInterval(this._shadeInInterval);this._shadeInInterval=false}var s=e?0:3;this._shadeInInterval=setInterval(function(){if(e)s++;else s--;t.pNewNameCont.className="bx-copy-new-name"+" bxcnn-"+s;if(s==0||s==3){clearInterval(t._shadeInInterval);t._shadeInInterval=false}},100)}};var BXFMInpSel=function(e){if(!e.Items||!e.Items.length||!e.pInput)return;if(e.popupWidth&&!isNaN(parseInt(e.popupWidth)))this.popupWidth=parseInt(e.popupWidth);this.id=e.id;this.Items=e.Items;this.pInput=e.pInput;this.posCorrection=e.posCorrection||{left:2,top:21};this.onChange=typeof e.OnChange=="function"?e.OnChange:false;this.onEnterPress=typeof e.OnEnterPress=="function"?e.OnEnterPress:false;this.NoValueMess=e.NoValueMess||"";this.selItemInd=false;BX.addClass(this.pInput,"bxfm-is-inp");var t=this;this.pInput.onclick=function(e){if(t.selItemInd!==false)t.DeSelectItem(t.selItemInd);if(this.value==t.NoValueMess){BX.removeClass(this,"bxfm-is-label");this.value=""}else if(this.value!=""){t.bCheckValue=true;t.CheckValue(false)}t.ShowPopup();return BX.PreventDefault(e)};this.pInput.onfocus=function(){if(this.value==t.NoValueMess){BX.removeClass(this,"bxfm-is-label");this.value=""}};this.pInput.onblur=function(){if(!t.bPopupShowed)t.OnChange()};if(this.pInput.value==""){this.OnChange(false)}this.pInput.autocomplete="off";this.pInput.onkeyup=function(e){if(t.bDenyOpenPopup)return true;if(!e)e=window.event;if(!e.altKey&&!e.ctrlKey&&e.keyCode!=17&&e.keyCode!=18&&e.keyCode!=16&&e.keyCode!=27&&e.keyCode!=13)return t.CheckValue(true)};this.pInput.onkeydown=function(e){return t.OnKeyDown(e)}};function BXFMPack(e){this.Init(e)}BXFMPack.prototype={Init:function(e){if(this.bInited)return true;this.oPackDialog=e.oPackDialog;BX.addClass(this.oPackDialog.PARTS.CONTENT,"bx-fm-pack-dialog");BX.cleanNode(this.oPackDialog.PARTS.CONTENT_DATA);this.oPackDialog.PARTS.CONTENT_DATA.appendChild(BX("bx_pack_dialog"));this.arLastPathes=e.arLastPathes;this.pPackCancel=BX("cancel-pack");this.pPackCancel.onclick=function(){if(t.bPacking){t.oPackDialog.SetTitle(FM_MESS.PackFinishing);t.bStopPacking=true;if(t.Params&&t.Params.fileOld){t.Params.fileOld=null;t.bPacking=false;t.oPackDialog.Close()}}else{t.oPackDialog.Close()}};var t=this;this.pCopyTbl=BX("bx_pack_table");this.pFilelist=BX("bx_pack_file_list");this.pPackTo=BX("bx_pack_to");this.pCaseReplace=BX("bx_pack_replace");this.pCaseSkip=BX("bx_pack_skip");this.pCaseReplace.onclick=this.pCaseSkip.onclick=function(){if(this.checked)t.caseOption=this.value};this.lang=e.lang;this.site=e.site;this.sessid_get=e.sessid_get;BX("bx_pack_dialog").style.display="block";this.viewMsFilePath=e.viewMsFilePath;this.viewMsFolderPath=e.viewMsFolderPath;this.oArcTypeSel=new BXFMArcTypeSel({id:"arc_type_pack",pDiv:BX("bx_pack_arc_type"),types:e.arTypes,bPack:true,typeChangeCallback:function(e){t.ChangeType(e)}});this.oPackTo=new BXFMInpSel({id:"cm_pack_to",pInput:this.pPackTo,Items:this.arLastPathes});this.oSiteSel=new BXFMSiteSel({id:"site_sel_pack",pDiv:BX("bx_pack_site_sel"),sites:e.arSites});this.caseOption="skip";BX.removeClass(t.pCopyTbl,"bx-pack-cont-tbl-add-hide");switch(this.caseOption){case"replace":this.pCaseReplace.checked=true;break;case"skip":this.pCaseSkip.checked=true;break}BX.addCustomEvent(this.oPackDialog,"onWindowUnRegister",BX.proxy(this.OnClose,this));this.pCaseSkip=BX("bx_pack_skip");this.pCaseReplace.onclick=this.pCaseSkip.onclick=function(){if(this.checked)t.caseOption=this.value};BX.addCustomEvent(this.oPackDialog,"onBeforeWindowClose",function(){t.oPackDialog.denyClose=false;if(t.bPacking){if(!t.forceClose){t.oPackDialog.SetTitle(FM_MESS.PackFinishing);t.bStopPacking=true;if(t.Params&&t.Params.fileOld)t.Params.fileOld=null;else t.oPackDialog.denyClose=true}}});this.bInited=true},OnOpen:function(e){this.bPack=e.bPack;this.arFiles=[];this.curPath=e.path;this.bStopPacking=false;this.bPacking=false;this.forceClose=false;this.bSearch=!!e.bSearch;this.searchSess=e.ssess;if(typeof e.arFiles=="object")this.arFiles=e.arFiles;if(e.arFiles[0]&&e.arFiles[0]=="action_target")this.arFiles=[{path:e.path,isDir:"1"}];var t=this.oPackDialog.PARAMS.buttons[1];t.btn.value=FM_MESS.PackCancel;clearInterval(this.counterID);this.pPackTo.value=this.GeneratePath(this.bPack,this.arFiles,"."+this.oArcTypeSel.value.toLowerCase());var s=this.oPackDialog.PARAMS.buttons[0];if(this.bPack){this.oPackDialog.SetTitle(FM_MESS.PackTitle);s.btn.value=s.title=FM_MESS.Pack;if(this.oArcTypeSel.arcTypes.length==1){BX.addClass(this.oArcTypeSel.pDiv,"bx-fm-non-selectable");BX.unbindAll(this.oArcTypeSel.pDiv)}else{BX.removeClass(this.oArcTypeSel.pDiv,"bx-fm-non-selectable");BX.bind(this.oArcTypeSel.pDiv,"click",BX.proxy(this.oArcTypeSel.ShowPopup,this.oArcTypeSel))}BX("bxfm-arctype-line").style.display="table-row";BX("bxfm-pack-option-replace").style.display="none";BX("bxfm-pack-option-skip").style.display="none";BX("bx-pack-d-title-label").style.display="none";this.pCaseSkip.checked=true;this.caseOption="ask"}else{this.oPackDialog.SetTitle(FM_MESS.UnpackTitle);s.btn.value=s.title=FM_MESS.Unpack;BX("bxfm-arctype-line").style.display="none";BX("bx-pack-d-title-label").style.display="table-row";BX("bxfm-pack-option-skip").style.display="table-row";BX("bxfm-pack-option-replace").style.display="table-row";this.pCaseSkip.checked=true;this.caseOption="skip"}BX("ok-pack").disabled=false;BX.cleanNode(this.pFilelist);var i,a=this.arFiles.length;for(i=0;i<a;i++){this.pFilelist.appendChild(BX.create("A",{props:{href:this.GetViewUrl(this.arFiles[i],this.site),target:"_blank"},text:this.GetFileName(this.arFiles[i])}));if(i==1&&a>3){this.pFilelist.appendChild(document.createTextNode(" ("+FM_MESS.More.replace("#COUNT#",parseInt(a-i-1))+")"));break}else if(i<a-1){this.pFilelist.appendChild(document.createTextNode(", "))}}this.oPackDialog.adjustSizeEx();BX.bind(BX.browser.IsIE()?document.body:window,"keydown",BX.proxy(this.OnKeyDown,this))},OnClose:function(){clearInterval(this.counterID);BX.unbind(BX.browser.IsIE()?document.body:window,"keydown",BX.proxy(this.OnKeyDown,this))},OnKeyDown:function(e){if(!e)e=window.event;if(window.oBXFileDialog&&window.oBXFileDialog.bOpened)return;if(this.oPackDialog.isOpen&&e.keyCode==13&&(!this.oAskUserDialog||!this.oAskUserDialog.isOpen))return this.Process()},Process:function(e){var t=null;if(e){switch(e.userCase){case"rename":var s=this.GetFolderPath(this.pPackTo.value);this.pPackTo.value=s+e.newName;break;case"replace":t="replace";break}}var i=this,a=this.bPack?"pack":"unpack",l={case_option:this.caseOption,files:this.arFiles,packTo:this.pPackTo.value,siteTo:this.oSiteSel.value,startFile:"",quickPath:BX("quick_path").value,arcType:this.oArcTypeSel.value,bPackReplace:t};if(this.counterID)clearInterval(this.counterID);BX("ok-pack").disabled=true;this.counterID=setInterval(function(){if(i.oPackDialog.PARAMS.title.split(".").length-1<3){this.oPackDialog.SetTitle(i.oPackDialog.PARAMS.title+" .")}else{this.oPackDialog.SetTitle(i.oPackDialog.PARAMS.title.split(" .")[0])}},500);var o=function(){if(!i.oPackDialog.isOpen)return;if(i.bStopPacking){if(i.bPack&&!window.BXFM_archiveExists){var e=i.GetFileName(l.packTo),t=i.GetFolderPath(l.packTo),s="/bitrix/admin/fileman_admin.php?action=delete&ID="+e+"&path="+t+"&"+i.sessid_get+"&lang="+i.lang+"&site="+i.site;i.bStopPacking=false;tbl_fileman_admin.GetAdminList(s,function(){i.forceClose=true;i.oPackDialog.Close()});return}else{i.forceClose=true;i.oPackDialog.Close();return}}if(window.BXFM_archivePermsError){alert(FM_MESS.PackPermsError);BX("ok-pack").disabled=false;window.BXFM_archivePermsError=null;i.oPackDialog.Close()}else if(window.BXFM_archiveExists){i.ShowAskUserDialog(window.BXFM_archiveExists);window.BXFM_archiveExists=null;BX("ok-pack").disabled=false}else if(window.BXFM_archiveFNameError){alert(FM_MESS.PackFNameError);BX("ok-pack").disabled=false;window.BXFM_archiveFNameError=null;i.forceClose=true;i.oPackDialog.Close()}else{switch(a){case"pack":if(window.fmPackTimeout){l.startFile=window.fmPackLastFile}else{if(window.fmPackSuccess){i.forceClose=true;i.oPackDialog.Close();var n=i.GetFolderPath(l.packTo);n=n.length==n.lastIndexOf("/")+1&&n.length!==1?n.substr(0,n.length-1):n;window.location=(i.viewMsFolderPath+i.oSiteSel.value).replace("#PATH#",BX.util.urlencode(n));return}else{if(window.fmPackErrors)alert(FM_MESS.PackError+": "+window.fmPackErrors);else alert(FM_MESS.PackError);BX.closeWait();i.forceClose=true;i.oPackDialog.Close();return}}break;case"unpack":if(window.fmUnpackSuccess){i.forceClose=true;i.oPackDialog.Close();var n=i.GetFolderPath(l.packTo);n=n.length==n.lastIndexOf("/")+1&&n.length!==1?n.substr(0,n.length-1):n;window.location=(i.viewMsFolderPath+l.siteTo).replace("#PATH#",BX.util.urlencode(n));return}else{if(window.fmUnpackErrors)alert(FM_MESS.UnpackError+": "+window.fmUnpackErrors);else alert(FM_MESS.UnpackError);BX.closeWait();i.forceClose=true;i.oPackDialog.Close();return}break}if(a=="pack"){if(i.rq)i.rq.abort();i.rq=i.Request(a,l,o)}}};this.bPacking=true;this.rq=this.Request(a,l,o)},GetFolderPath:function(e){var t=e;var s=t.lastIndexOf("/");if(s!="-1"){t=t.slice(0,s)}if(t!="/")t+="/";return t},GetFileName:function(e){if(typeof e=="object")e=e.path;var t=e,s=e.lastIndexOf("/");if(s!==-1&&e.length!==1)t=e.substr(s+1);return t},MakeArchiveName:function(e){var t=e.substr(e.lastIndexOf("/")+1);if(t.slice(-7)==".tar.gz"){t=t.slice(0,-7)}else{if(t.lastIndexOf(".")!=-1&&t.lastIndexOf(".")!=0)t=t.slice(0,t.lastIndexOf("."))}return t},MakeFolderArchiveName:function(e){var t=e.substr(e.lastIndexOf("/")+1);return t},GeneratePath:function(e,t,s){if(e&&t.length==1&&!!t[0].isDir==true){return this.GetFolderPath(t[0].path)+this.MakeFolderArchiveName(t[0].path)+s}if(e&&t.length>0){var i=t.length==1?t[0].path:"archive";return this.GetFolderPath(this.arFiles[0].path)+this.MakeArchiveName(i)+s}if(!e){var a=t[0];return this.GetFolderPath(a)}},ChangeType:function(e){e=e.toLowerCase();if(this.arFiles)this.pPackTo.value=this.GeneratePath(this.bPack,this.arFiles,"."+e)},GetViewUrl:function(e,t){if(typeof e=="object")return((e.isDir?this.viewMsFolderPath:this.viewMsFilePath)+t).replace("#PATH#",BX.util.urlencode(e.path));return(this.viewMsFilePath+t).replace("#PATH#",BX.util.urlencode(e))},Request:function(e,t,s,i){i=i!==false;if(i)BX.showWait();var a="/bitrix/admin/fileman_admin.php?lang="+this.lang+"&fu_action="+e+"&site="+this.site+"&"+this.sessid_get;if(e=="pack"){BX.addClass(this.oArcTypeSel.pDiv,"bx-fm-non-selectable");BX.unbindAll(this.oArcTypeSel.pDiv)}return BX.ajax.post(a,t||{},function(e){if(i)BX.closeWait();if(s)setTimeout(function(){s(e)},100)})},ShowAskUserDialog:function(e){var t=this;t.Params=e;if(!this.oAskUserDialog){this.oAskUserDialog=new BX.CAdminDialog({title:"",content:"&nbsp;",height:240,width:500,resizable:false});this.oAskUserDialog.SetButtons([new BX.CWindowButton({title:FM_MESS.Replace,name:"replace",action:function(){t.UserAnswer("replace")}}),new BX.CWindowButton({title:FM_MESS.Rename,name:"rename",action:function(){var e=prompt(FM_MESS.AskNewName,t.Params.fileOld.name);t.Params.fileOld.name=null;if(e)t.UserAnswer("rename",e)}}),this.oAskUserDialog.btnCancel]);BX.addClass(this.oAskUserDialog.PARTS.CONTENT,"bx-fm-pack-dialog");BX.addClass(this.oAskUserDialog.PARTS.FOOT,"bx-core-dialog-foot-ask");setTimeout(function(){var e=BX("bx_pack_ask_dialog");t.oAskUserDialog.SetContent(e);e.style.display="block";t.oAskUserDialog.adjustSizeEx()},50);this.pAskFileName=BX("bx_pack_ask_file_name");this.pAskFolderName=BX("bx_pack_ask_folder");this.pAskSizeRow=BX("bx_pack_ask_size_row");this.pAskFileOld={pName:BX("bx_pack_ask_file2"),pSize:BX("bx_pack_ask_size2"),pDate:BX("bx_pack_ask_date2")};this.pRenBut=this.oAskUserDialog.PARAMS.buttons[2].btn;BX.addCustomEvent(this.oAskUserDialog,"onWindowUnRegister",function(){t.oPackTo.bDenyOpenPopup=false})}this.oAskUserDialog.Show();if(t.counterID)clearInterval(t.counterID);this.oPackTo.bDenyOpenPopup=true;this.oAskUserDialog.adjustSizeEx();this.oAskUserDialog.SetTitle(FM_MESS.FileExistTitle);this.pAskFileName.innerHTML=e.fileOld.name;this.pAskFolderName.innerHTML=t.GetFolderPath(this.pPackTo.value);this.pAskFileOld.pName.innerHTML=this.pAskFileOld.pName.title=e.fileOld.name;this.pAskFileOld.pName.href=this.GetViewUrl(e.fileOld.path,e.fileOld.site);this.pAskFileOld.pDate.innerHTML=e.fileOld.date;this.pAskFileOld.pSize.innerHTML=e.fileOld.size},UserAnswer:function(e,t){if(e=="replace")this.Params=null;this.Process({userCase:e,newName:t});this.oAskUserDialog.Close()}};BXFMInpSel.prototype={ShowPopup:function(e){if(this.bPopupShowed||this.bDenyOpenPopup)return;var t=this;if(e!==false)this.pInput.select();if(!this.bPopupCreated)this.CreatePopup();this.Popup.style.display="block";this.bPopupShowed=true;setTimeout(function(){BX.bind(document,"click",BX.proxy(t.ClosePopup,t))},100);var s=jsUtils.GetRealPos(this.pInput);jsFloatDiv.Show(this.Popup,s.left+this.posCorrection.left,s.top+this.posCorrection.top,3);BX.WindowManager.disableKeyCheck()},ClosePopup:function(e){BX.unbind(document,"click",BX.proxy(this.ClosePopup,this));setTimeout(function(){BX.WindowManager.enableKeyCheck()},200);if(!this.Popup||!this.pInput)return;this.Popup.style.display="none";this.bPopupShowed=false;jsFloatDiv.Close(this.Popup);if(e!==false&&this.pInput.value=="")this.OnChange();if(this.pInput.focus)this.pInput.focus()},CreatePopup:function(){var e=this,t,s,i=this.Items.length;this.Popup=document.body.appendChild(BX.create("DIV",{props:{className:"bxfm-is-popup"}}));if(!this.popupWidth)this.Popup.style.width=parseInt(this.pInput.offsetWidth)+"px";this.bPopupCreated=true;for(s=0;s<i;s++){t=this.Popup.appendChild(BX.create("DIV",{props:{id:"bx_"+this.id+"_"+s,title:this.Items[s].name||this.Items[s].title,className:"bxfm-is-item"},text:this.Items[s].name,events:{mouseover:function(){BX.addClass(this,"bxfm-is-item-over")},mouseout:function(){BX.removeClass(this,"bxfm-is-item-over")},click:function(){var t=this.id.substr(("bx_"+e.id+"_").length);e.curInd=t;e.pInput.value=e.Items[t].name;e.OnChange();e.ClosePopup()}}}));this.Items[s].pCont=t}},OnChange:function(e){var t=this.pInput.value;if(t==""||t==this.NoValueMess){BX.addClass(this.pInput,"bxfm-is-label");this.pInput.value=this.NoValueMess;t=""}else{BX.removeClass(this.pInput,"bxfm-is-label")}if(this.onChange&&e!==false)this.onChange({value:t})},CheckValue:function(e,t){if(!this.bCheckValue)return;var s=false,i,a,l=this.Items.length,o=this.pInput.value;for(a=0;a<l;a++){i=this.Items[a].name;if(i.length>o.length&&i.substr(0,o.length)==o||i==o){this.SelectItem(a,e);s=true;break}}if(!s&&t!==false){if(this.selItemInd!==false)this.DeSelectItem(this.selItemInd);this.ClosePopup(false)}},SelectItem:function(e,t){if(!this.bPopupShowed)this.ShowPopup(false);if(this.selItemInd!==false)this.DeSelectItem(this.selItemInd);var s=this.Items[e].pCont;if(t){var i=this.pInput.value.length;BX.cleanNode(s);s.appendChild(BX.create("SPAN",{props:{className:"bxfm-highlighted"},text:this.Items[e].name.substr(0,i)}));s.appendChild(document.createTextNode(this.Items[e].name.substr(i)))}this.selItemInd=e;BX.addClass(s,"bxfm-is-item-concur")},DeSelectItem:function(e){BX.cleanNode(this.Items[e].pCont);this.Items[e].pCont.appendChild(document.createTextNode(this.Items[e].name));BX.removeClass(this.Items[e].pCont,"bxfm-is-item-concur");this.selItemInd=false},OnKeyDown:function(e){if(this.bDenyOpenPopup)return true;if(window.oBXFileDialog&&window.oBXFileDialog.bOpened)return;this.bCheckValue=true;if(!e)e=window.event;if(e.keyCode==13){if(!this.bPopupShowed){if(this.onEnterPress){this.onEnterPress({value:this.pInput.value});return BX.PreventDefault(e)}this.bCheckValue=false;return}if(this.selItemInd){this.bCheckValue=false;this.OnChange();this.ClosePopup();return BX.PreventDefault(e)}}else if(e.keyCode==27){if(!this.bPopupShowed)return;this.ClosePopup();this.bCheckValue=false;return BX.PreventDefault(e)}else if(e.keyCode==40||e.keyCode==38){var t;if(e.keyCode==40){if(!this.bPopupShowed){this.CheckValue(false,false);this.bCheckValue=false;this.ShowPopup(false);return}t=this.selItemInd===false?0:this.selItemInd+1;if(t>this.Items.length-1)t=0}else{if(!this.bPopupShowed)return;t=this.selItemInd===false?this.Items.length-1:this.selItemInd-1;if(t<0)t=this.Items.length-1}this.pInput.value=this.Items[t].name;this.SelectItem(t,false);this.bCheckValue=false;return BX.PreventDefault(e)}else if(e.keyCode==39){if(this.selItemInd!==false&&this.bPopupShowed){this.pInput.value=this.Items[this.selItemInd].name;this.SelectItem(this.selItemInd,false);this.bCheckValue=false;this.ClosePopup()}}}};var BXFMSiteSel=function(e){this.pDiv=e.pDiv;this.sites=e.sites;var t,s=this.sites.length;if(s==1){this.bOne=true;this.pDiv.style.display="none";return this.SetSite(0,false)}this.pTitle=this.pDiv.appendChild(BX.create("DIV"));this.pDiv.onclick=BX.proxy(this.ShowPopup,this);this.id=e.id||"site_sel";for(t=0;t<s;t++){if(this.sites[t].current){this.SetSite(t,false);break}}};BXFMSiteSel.prototype={ShowPopup:function(){if(this.bShowed)return this.ClosePopup();this.bShowed=true;var e=this;if(!this.bCreated)this.CreatePopup();var t=BX.pos(this.pDiv);this.Popup.style.display="block";this.Popup.style.top=t.top+18+"px";this.Popup.style.left=t.left+"px";BX.ZIndexManager.bringToFront(this.Popup);BX.WindowManager.disableKeyCheck();setTimeout(function(){BX.bind(document,"click",BX.proxy(e.ClosePopup,e))},100);BX.bind(document,"keydown",BX.proxy(this.OnKeyDown,this))},ClosePopup:function(){BX.unbind(document,"click",BX.proxy(this.ClosePopup,this));BX.unbind(document,"keydown",BX.proxy(this.OnKeyDown,this));setTimeout(function(){BX.WindowManager.enableKeyCheck()},200);if(!this.Popup)return;this.Popup.style.display="none";this.bShowed=false},CreatePopup:function(){var e=this,t,s,i,a=this.sites.length;this.Popup=document.body.appendChild(BX.create("DIV",{props:{className:"bxfm-at-is-popup"}}));BX.ZIndexManager.register(this.Popup);this.Popup.style.width="200px";this.bCreated=true;for(i=0;i<a;i++){t=this.sites[i];s=this.Popup.appendChild(BX.create("SPAN",{props:{id:"bx_"+this.id+"_"+i,title:BX.util.htmlspecialchars(t.text),className:"bxfm-site-sel-it"},events:{mouseover:function(){BX.addClass(this,"bxfm-ss-over")},mouseout:function(){BX.removeClass(this,"bxfm-ss-over")},click:function(){var t=this.id.substr(("bx_"+e.id+"_").length);e.SetSite(parseInt(t),true);e.ClosePopup()}}}));s.appendChild(BX.create("DIV",{props:{className:"bxfm-text-overflow"},text:t.text}));if(this.curSiteInd===i)BX.addClass(s,"bxfm-ss-checked");this.sites[i].row=s}},SetSite:function(e){var t=this.sites[e];if(!t)return;if(!this.bOne&&typeof this.curSiteInd!="undefined"&&this.sites[this.curSiteInd]&&this.sites[this.curSiteInd].row)BX.removeClass(this.sites[this.curSiteInd].row,"bxfm-ss-checked");this.value=t.id;this.curSiteInd=e;BX("bx_copy_to").value=t["dir"];BX("bx_copy_to").focus();if(this.bOne)return;this.pTitle.innerHTML=t.id.toUpperCase();if(this.sites[e].row)BX.addClass(this.sites[e].row,"bxfm-ss-checked")},OnKeyDown:function(e){if(!e)e=window.event;if(window.oBXFileDialog&&window.oBXFileDialog.bOpened)return;if(e.keyCode==27)return this.ClosePopup()}};var BXFMArcTypeSel=function(e){this.pDiv=e.pDiv;this.arcTypes=e.types;this.bPack=e.bPack;this.typeChangeCallback=e.typeChangeCallback;var t=this.arcTypes.length;if(t==1){this.bOne=true;BX.addClass(this.pDiv,"bx-fm-non-selectable");this.pDiv.innerHTML=this.arcTypes[0].text.toUpperCase();return this.SetArcType(0,false)}this.pTitle=this.pDiv.appendChild(BX.create("DIV"));BX.bind(this.pDiv,"click",BX.proxy(this.ShowPopup,this));this.id=e.id||"arc_type_pack";this.SetArcType(0,false)};BXFMArcTypeSel.prototype={ShowPopup:function(){if(this.bShowed)return this.ClosePopup();this.bShowed=true;var e=this;if(!this.bCreated)this.CreatePopup();var t=BX.pos(this.pDiv);this.Popup.style.display="block";this.Popup.style.top=t.top+18+"px";this.Popup.style.left=t.left+"px";BX.ZIndexManager.bringToFront(this.Popup);BX.WindowManager.disableKeyCheck();setTimeout(function(){BX.bind(document,"click",BX.proxy(e.ClosePopup,e))},100);BX.bind(document,"keydown",BX.proxy(this.OnKeyDown,this))},ClosePopup:function(){BX.unbind(document,"click",BX.proxy(this.ClosePopup,this));BX.unbind(document,"keydown",BX.proxy(this.OnKeyDown,this));setTimeout(function(){BX.WindowManager.enableKeyCheck()},200);if(!this.Popup)return;this.Popup.style.display="none";this.bShowed=false},CreatePopup:function(){var e=this,t,s,i,a=this.arcTypes.length;this.Popup=document.body.appendChild(BX.create("DIV",{props:{className:"bxfm-at-is-popup"}}));this.Popup.style.width="260px";this.bCreated=true;BX.ZIndexManager.register(this.Popup);for(i=0;i<a;i++){t=this.arcTypes[i];s=this.Popup.appendChild(BX.create("DIV",{props:{id:"bx_"+this.id+"_"+i,title:BX.util.htmlspecialchars(t.text),className:"bxfm-arc-type-it"},events:{mouseover:function(){BX.addClass(this,"bxfm-at-over")},mouseout:function(){BX.removeClass(this,"bxfm-at-over")},click:function(){var t=this.id.substr(("bx_"+e.id+"_").length);e.SetArcType(parseInt(t),true);e.ClosePopup()}}}));s.appendChild(BX.create("DIV",{props:{className:"bxfm-text-overflow"},text:t.text}));if(this.curArcTypeInd===i)BX.addClass(s,"bxfm-at-checked");this.arcTypes[i].row=s}},SetArcType:function(e){var t=this.arcTypes[e];if(!t)return;if(!this.bOne&&typeof this.curArcTypeInd!="undefined"&&this.arcTypes[this.curArcTypeInd]&&this.arcTypes[this.curArcTypeInd].row)BX.removeClass(this.arcTypes[this.curArcTypeInd].row,"bxfm-at-checked");this.value=t.id;this.curArcTypeInd=e;if(this.bOne)return;this.pTitle.innerHTML=t.text.toUpperCase();if(this.bPack)this.typeChangeCallback(this.pTitle.innerHTML);if(this.arcTypes[e].row)BX.addClass(this.arcTypes[e].row,"bxfm-at-checked")},OnKeyDown:function(e){if(!e)e=window.event;if(window.oBXFileDialog&&window.oBXFileDialog.bOpened)return;if(e.keyCode==27)return this.ClosePopup()}};
//# sourceMappingURL=fileman_utils.map.js